// 书写 登录的路由规则

const express = require('express')
const path = require('path')

// express 使用的中间件函数，进行校验
const expressJoi = require('@escook/express-joi')

const { add_article_schema } = require('../schema/article')

// 必须使用 .. 
const articleHandler = require('../router_handler/article')

const router = express.Router()

const multer = require('multer')
const upload = multer({ dest: path.join(__dirname, '../uploads') })

// 发布文章
router.post('/add',
    upload.single('cover_img'),
    expressJoi(add_article_schema),
    articleHandler.addArticle
)

// 查询文章列表
router.get('/list',
    articleHandler.getList)


// 更新用户的头像
// router.post('/update/avatar',
//     expressJoi(update_avatar_schema),
//     userinfoHandler.updateUserAvatar)




module.exports = router